package com.AAL.DAO;

import java.util.List;

import org.hibernate.classic.Session;

import com.AAL.DAO.Interface.IUpdatingOrderDAO;
import com.AAL.Model.Order;
import com.AAL.Model.UpdatingOrder;
import com.AAL.Utils.HibernateUtil;

public class UpdatingOrderDAO implements IUpdatingOrderDAO {

	@Override
	public UpdatingOrder saveAndUpdateUpdatingOrder(UpdatingOrder updatingOrder) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		try {
			session.saveOrUpdate(updatingOrder);
		} catch (Exception e) {
			System.out.println("E:"+ e.getMessage());
			return null;
		}
		session.getTransaction().commit();
		return updatingOrder;
	}

	@Override
	public UpdatingOrder deleteUpdatingOrder(int updatingOrder) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public UpdatingOrder getUpdatingOrder(int updatingOrderID) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		UpdatingOrder updatingOrder = (UpdatingOrder) session.load(
				UpdatingOrder.class, updatingOrderID);
		return updatingOrder;
	}

	@Override
	public List<UpdatingOrder> getLstUpdatingOrder(Order order) {
		// TODO Auto-generated method stub
		return null;
	}

}
